linux: e820 handling adjustments
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 15 Feb 2007 14:05:58 +0000 (14:05 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 15 Feb 2007 14:05:58 +0000 (14:05 +0000)
In certain places, machine_e820 should be used rather than e820.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c
linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c
linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c

index 4d0d6e05584ce6ffde6c3e762dbf9cfe59ab30e9..8afbd64e64bc45529c7d7233cd1977b67b509f45 100644 (file)
@@ -1034,8 +1034,16 @@ e820_all_mapped(unsigned long s, unsigned long e, unsigned type)
        u64 start = s;
        u64 end = e;
        int i;
+
+#ifndef CONFIG_XEN
        for (i = 0; i < e820.nr_map; i++) {
                struct e820entry *ei = &e820.map[i];
+#else
+       if (!is_initial_xendomain())
+               return 0;
+       for (i = 0; i < machine_e820.nr_map; ++i) {
+               const struct e820entry *ei = &machine_e820.map[i];
+#endif
                if (type && ei->type != type)
                        continue;
                /* is the region (part) in overlap with the current region ?*/
@@ -1505,9 +1513,6 @@ e820_setup_gap(struct e820entry *e820, int nr_map)
  */
 static int __init request_standard_resources(void)
 {
-#ifdef CONFIG_XEN
-       struct xen_memory_map memmap;
-#endif
        int           i;
 
        /* Nothing to do if not running in dom0. */
@@ -1516,13 +1521,6 @@ static int __init request_standard_resources(void)
 
        printk("Setting up standard PCI resources\n");
 #ifdef CONFIG_XEN
-       memmap.nr_entries = E820MAX;
-       set_xen_guest_handle(memmap.buffer, machine_e820.map);
-
-       if (HYPERVISOR_memory_op(XENMEM_machine_memory_map, &memmap))
-               BUG();
-       machine_e820.nr_map = memmap.nr_entries;
-
        legacy_init_iomem_resources(machine_e820.map, machine_e820.nr_map,
                                    &code_resource, &data_resource);
 #else
@@ -1546,12 +1544,22 @@ subsys_initcall(request_standard_resources);
 
 static void __init register_memory(void)
 {
-
 #ifdef CONFIG_XEN
-       e820_setup_gap(machine_e820.map, machine_e820.nr_map);
-#else
-       e820_setup_gap(e820.map, e820.nr_map);
+       if (is_initial_xendomain()) {
+               struct xen_memory_map memmap;
+
+               memmap.nr_entries = E820MAX;
+               set_xen_guest_handle(memmap.buffer, machine_e820.map);
+
+               if (HYPERVISOR_memory_op(XENMEM_machine_memory_map, &memmap))
+                       BUG();
+
+               machine_e820.nr_map = memmap.nr_entries;
+               e820_setup_gap(machine_e820.map, machine_e820.nr_map);
+       }
+       else
 #endif
+               e820_setup_gap(e820.map, e820.nr_map);
 }
 
 #ifdef CONFIG_MCA
index 250501fd08cff6dfeb3c9e5196abffbf9667fddf..29c0bb2b91cd5f36f8346bd0d940f977b805fb15 100644 (file)
@@ -127,8 +127,19 @@ e820_any_mapped(unsigned long start, unsigned long end, unsigned type)
 int __init e820_all_mapped(unsigned long start, unsigned long end, unsigned type)
 {
        int i;
+
+#ifndef CONFIG_XEN
        for (i = 0; i < e820.nr_map; i++) {
                struct e820entry *ei = &e820.map[i];
+#else
+       extern struct e820map machine_e820;
+
+       if (!is_initial_xendomain())
+               return 0;
+       for (i = 0; i < machine_e820.nr_map; i++) {
+               const struct e820entry *ei = &machine_e820.map[i];
+#endif
+
                if (type && ei->type != type)
                        continue;
                /* is the region (part) in overlap with the current region ?*/
index f49110cf904e7e5958eeed0e800dc2985e95a1c1..80ef5cfabccbcc48ad77ae52e837f251910c75d9 100644 (file)
@@ -585,8 +585,6 @@ static void discover_ebda(void)
 void __init setup_arch(char **cmdline_p)
 {
 #ifdef CONFIG_XEN
-       struct xen_memory_map memmap;
-
        /* Register a call for panic conditions. */
        atomic_notifier_chain_register(&panic_notifier_list, &xen_panic_block);
 
@@ -895,6 +893,8 @@ void __init setup_arch(char **cmdline_p)
        probe_roms();
 #ifdef CONFIG_XEN
        if (is_initial_xendomain()) {
+               struct xen_memory_map memmap;
+
                memmap.nr_entries = E820MAX;
                set_xen_guest_handle(memmap.buffer, machine_e820.map);